aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/address/+page.server.js
blob: c18bcdba676c02ab08a60fc3da4a1acda44f2310 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { auth, get, post } from '$lib/utils';
import { redirect } from '@sveltejs/kit';

export async function load({ cookies, params, parent }) {
	let user = (await parent()).subject;
	let rates = await get('/rates');
	let invoice = {
		network: 'bitcoin',
		rate: rates[user.currency]
	};
	let { uuid } = await post('/invoice', { invoice, user }, auth(cookies));
	throw redirect(307, `/invoice/${uuid}`);
}